import 'package:flutter/material.dart';

class RoundCheckBox extends StatefulWidget {
  final bool value;
  final ValueChanged<bool> onChanged;

  RoundCheckBox({Key key, this.value, this.onChanged}) : super(key: key);

  @override
  _RoundCheckBoxState createState() => _RoundCheckBoxState();
}

class _RoundCheckBoxState extends State<RoundCheckBox> {
  bool _status = false;

  @override
  void initState() {
    super.initState();
    _status = widget.value ?? false;
  }

  @override
  Widget build(BuildContext context) {
    return Center(
      child: GestureDetector(
          onTap: () {
            setState(() {
              _status = !_status;
            });
            if (widget.onChanged != null) {
              widget.onChanged(_status);
            }
          },
          child: Padding(
            padding: const EdgeInsets.all(10.0),
            child: _status
                ? Icon(
                    Icons.check_circle_outline,
                    size: 24.0,
                    color: Theme.of(context).primaryColor,
                  )
                : Icon(
                    Icons.panorama_fish_eye,
                    size: 24.0,
                    color: Colors.grey,
                  ),
          )),
    );
  }
}
